package com.swy.shopgroup.service.impl;


import com.swy.shopgroup.ResultUtils;
import com.swy.shopgroup.dao.ShopInfoMapper;
import com.swy.shopgroup.dao.ShopUserMapper;
import com.swy.shopgroup.entity.Result;
import com.swy.shopgroup.entity.ShopInfo;
import com.swy.shopgroup.entity.ShopUser;
import com.swy.shopgroup.service.ShopService;
import com.swy.shopgroup.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class ShopServiceImpl implements ShopService {

    @Resource
    ShopInfoMapper infoMapper;

    @Override
    public Result selectShopByState(int state) {
        return ResultUtils.success("查询成功", infoMapper.selectShopByState(state));
    }

    @Override
    public Result insertService(ShopInfo info) {
        return ResultUtils.success("查询成功", infoMapper.insert(info));
    }

    @Override
    public Result updateShop(Long id) {
        ShopInfo shopInfo = infoMapper.selectByPrimaryKey(id);
        shopInfo.setState(1);
        return ResultUtils.success("更新成功", infoMapper.updateByPrimaryKey(shopInfo));
    }

    @Override
    public Result selectByUser(Long id) {
        ShopInfo shopInfo = infoMapper.selectByUser(id);
        if (shopInfo != null) {
            return ResultUtils.success("查询成功", shopInfo);
        }else{
            return ResultUtils.err("暂未入驻");
        }
    }
}
